const query = require('../util/sql')
module.exports = async (ctx, next) => {
	let newsId = ctx.request.query.newsId
	let sql;
	
	sql = `select * from news where id=${newsId} and isDel=0`;
	let data = await query(sql)
	
	sql =`select * from news where id=${parseInt(newsId)+1} and isDel=0`;
	let nextData = await query(sql);

	sql =`select * from news where id=${parseInt(newsId)-1} and isDel=0`;
	let prevData = await query(sql);
	if(data!=''){
	  data[0].prevNews = prevData[0];
	  data[0].nextNews = nextData[0];
	  ctx.state.data = data[0]
	}else{
	  ctx.state.data ={};
	}	
}	
